$(function() {
	$(document).ready(function() {
	});
	function CreateTV(results)
	{
		var isIECore='';
		if(!!window.ActiveXObject || "ActiveXObject" in window)
		    isIECore=true;
		else  
		    isIECore=false;
		
		var object_str="";
		
		var tr_str="<tr>";
		var tr_str_back="</tr>";
		
		var num=2;
		
		for(var i=0;i<results.length;i++){
			
			if(i%num==0){
				object_str+=tr_str;
			}
			
			if (isIECore) {	
				object_str+='<td><object useradress="'+results[i].interfaceAddress+'" userchannel="'+results[i].interfacePort+'" id="'+results[i].id+'_csocx" classid="clsid:59EA8A50-4FC1-406a-A471-595247AB2E41" codebase="/wcsi/tvfile/CISDITV.cab" width="100%" height="415px"></object></td>';
			}
			else {
				object_str+='<td><object useradress="'+results[i].interfaceAddress+'" userchannel="'+results[i].interfacePort+'" id="'+results[i].id+'_csocx" clsid="{59EA8A50-4FC1-406a-A471-595247AB2E41}" type="application/x-itst-activex"  progid="/wcsi/tvfile/CISDITV.cab" width="100%" height="415px"></object><td>';
			}
			if(i%num==(num-1)){
				object_str+=tr_str_back;
			}
		}
		
		$('#TVList').append("<tbody>"+object_str+"</tbody>");
		
		for(var i=0;i<results.length;i++){
			WatchTV(results[i].id+"_csocx");	
		}
	};
	function WatchTV(id)
	{
		var ocxKq = document.getElementById(id);
		var ocxKqj =$("#"+id);
		ocxKq.InstallView(ocxKqj.useradress,ocxKqj.userchannel); 
		ocxKq.OpenStream();
	};
});
